from sqlalchemy import BigInteger, CHAR, String, DECIMAL, DateTime, Integer, Column

from config.database import Base


class Trade(Base):
    """
    股票交易任务表
    """

    __tablename__ = 'stock_trade'
    __table_args__ = {'comment': '股票交易任务表'}

    id = Column(BigInteger, primary_key=True, autoincrement=True, nullable=False, comment='主键ID')
    stock_code = Column(String(20), nullable=False, comment='股票代码')
    direction = Column(CHAR(1), nullable=False, comment='交易方向：1买，2卖')
    price = Column(DECIMAL, nullable=False, comment='交易价')
    quantity = Column(Integer, nullable=False, comment='交易股数')
    source = Column(CHAR(1), nullable=False, comment='交易来源：1手动，2策略')
    account_no = Column(String(64), nullable=False, comment='交易账户')
    phase = Column(Integer, nullable=True, comment='任务阶段')
    status = Column(CHAR(1), nullable=False, comment='任务状态')
    create_by = Column(String(64), nullable=True, comment='创建人')
    create_time = Column(DateTime, nullable=True, comment='创建时间')
    update_by = Column(String(64), nullable=True, comment='更新人')
    update_time = Column(DateTime, nullable=True, comment='更新时间')
    remark = Column(String(500), nullable=True, comment='备注')
